from bisect import bisect_left
from typing import *
from math import floor, sqrt


class Solution:

    def repairCars(self, ranks: List[int], cars: int) -> int:
        l, r = 0, 100000000000000000
        while l < r:
            m = ((r - l) >> 1) + l
            s = 0
            for v in ranks:
                s += int(sqrt(m // v))
            if s >= cars:
                r = m
            else:
                l = m + 1
        return l


from math import log2

print(log2(100000000000000000))


class Solution:

    def repairCars(self, ranks: List[int], cars: int) -> int:
        s = lambda t: sum(floor(sqrt(t // r)) for r in ranks)
        return bisect_left(range(min(ranks) * cars * cars), cars, key=s)


class Solution:

    def repairCars(self, ranks: List[int], cars: int) -> int:
        return bisect_left(
            range(min(ranks) * cars * cars),
            cars,
            key=lambda t: sum(floor(sqrt(t // r)) for r in ranks))

print(10000 - 3610.2)